import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
//导入axios
import axios from 'axios'
// 配置请求的根路径
axios.defaults.baseURL = 'http://localhost:8888/'
axios.interceptors.request.use(config => {
  console.log(config)
  if (config.data instanceof FormData) {
    Object.assign(config.headers, config.data.getHeaders());
  }
  config.headers.Authorization = 'Bearer ' + window.sessionStorage.getItem('token')
  return config
  },error => {
    console.log(error)
  }
)
axios.interceptors.response.use(
  response => {
    return response
  },error => {
    return error.response
  }
)
Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  data: function () {
    return {
      userId: null,
      workNumber: '',
      token: '',
      name: '',
      roleId: null
    }
  },
  render: h => h(App)
}).$mount('#app')
